package com.njust.controller;

import com.njust.domain.dto.MessageDTO;
import com.njust.domain.dto.MessagePageQueryDTO;
import com.njust.domain.vo.PageQueryVO;
import com.njust.result.Result;
import com.njust.service.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @version 1.0
 * @Author Imak
 * @Date 2024/11/7 16:53
 * @留言板
 */
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/message")
@Slf4j
public class MessageController {
    @Autowired
    private MessageService messageService;

    /**
     * 新增留言接口
     * @param messageDTO
     * @return
     */
    @PostMapping("/addMessage")
    public Result<String> addMessage(@RequestBody MessageDTO messageDTO){
        messageService.addMessage(messageDTO);
        log.info("新增留言成功");
        return Result.success("留言成功!");
    }

    @GetMapping("/pageQuery")
    public Result<PageQueryVO> pageQuery(MessagePageQueryDTO messagePageQueryDTO){
        log.info("留言分页查询，参数为：{}",messagePageQueryDTO);
        PageQueryVO PageQueryVO=messageService.pageQuery(messagePageQueryDTO);
        return Result.success(PageQueryVO);
    }




}
